package xserver;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 游戏会话管理器
 * 
 * @author AfritXia
 * @version $Rev: 17 $
 *
 */
public final class XgameSessionManager {
	/**
	 * 游戏会话字典
	 * 
	 */
	public static Map<Long, XgameSession> _gameSessionMap = null;

	static {
		synchronized (XgameSessionManager.class) {
			_gameSessionMap = new ConcurrentHashMap<Long, XgameSession>();
		}
	}
	
	/**
	 * 类默认构造器
	 * 
	 */
	private XgameSessionManager() {
	}

	/**
	 * 设置游戏会话
	 * 
	 * @param sessionId
	 * @param session 
	 * 
	 */
	public static void putGameSession(long sessionId, XgameSession session) {
		if (sessionId <= 0 || session == null) {
			return;
		}

		_gameSessionMap.put(sessionId, session);
	}

	/**
	 * 获取游戏会话
	 * 
	 * @param sessionId
	 * @return 
	 * 
	 */
	public static XgameSession getGameSession(long sessionId) {
		if (sessionId <= 0) {
			return null;
		}

		return _gameSessionMap.get(sessionId);
	}
}
